package requrest

import (
	"go-project/dto"

	"github.com/gin-gonic/gin"
)

type OfficialAccountSettingRequest struct {
	Name           string `json:"name"`
	AppID          string `json:"app_id" binding:"required" required_msg:"app_id不能为空"`
	AppSecret      string `json:"app_secret" binding:"required" required_msg:"app_secret不能为空"`
	Token          string `json:"token"`
	EncodingAESKey string `json:"encoding_aes_key"`
	EncryptionType int8   `json:"encryption_type" binding:"required" required_msg:"消息加密方式不能为空"`
	dto.ValidateBindRequest
}

func (officialAccountSettingRequest *OfficialAccountSettingRequest) BindAndValidate(c *gin.Context) error {
	if err := c.ShouldBindJSON(officialAccountSettingRequest); err != nil {
		c.Errors = append(c.Errors, c.Error(err).SetType(gin.ErrorTypeBind))
		c.Set("req_dto", officialAccountSettingRequest)
		return err
	}
	return nil
}
